package com.xsy.android.compose.we.component.ui.page.chat.compose

import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.text.BasicTextField
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.SolidColor
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.xsy.android.compose.we.component.R
import com.xsy.android.compose.we.component.ui.theme.WeComposeTheme

/**
 *@author: xiaosy
 *时间: 2024/7/3
 *@Description: java类作用描述
 *@Version: 1.0
 **/
@Composable
fun ChatBottomBar(onBombClicked: (() -> Unit)? = null) {
    var editingText by remember {
        mutableStateOf("")
    }
    Row(
        Modifier
            .fillMaxWidth()
            .background(WeComposeTheme.colors.bottomBar)
            .padding(4.dp, 0.dp)
    ) {
        Icon(
            painter = painterResource(id = R.drawable.ic_voice),
            contentDescription = null,
            modifier = Modifier
                .align(Alignment.CenterVertically)
                .padding(4.dp)
                .size(28.dp)
        )
        BasicTextField(
            value = editingText,
            onValueChange = { editingText = it },
            modifier = Modifier
                .weight(1f)
                .padding(4.dp, 8.dp)
                .height(40.dp)
                .clip(MaterialTheme.shapes.small)
                .background(WeComposeTheme.colors.textFieldBackground)
                .padding(start = 8.dp, top = 10.dp, end = 8.dp),
            cursorBrush = SolidColor(WeComposeTheme.colors.textPrimary)

        )
        Text(
            text = "\uD83D\uDCA3",
            modifier = Modifier
                .clickable(onClick = onBombClicked ?: {})
                .padding(4.dp)
                .align(Alignment.CenterVertically),
            fontSize = 24.sp
        )
        Icon(
            painter = painterResource(id = R.drawable.ic_add),
            contentDescription = null,
            modifier = Modifier
                .align(Alignment.CenterVertically)
                .padding(4.dp)
                .size(28.dp),
            tint = WeComposeTheme.colors.icon
        )

    }
}

@Preview
@Composable
fun PreviewChatBottomBar() {
    ChatBottomBar()
}
